<?php echo $this->doctype() ?>
<html>
<head>
	<?php header("Content-type: text/html; charset=utf-8"); ?>
	<?php include_once 'components/topheader.phtml';?>
    <?php echo $this->headTitle() ?>
   	<?php echo $this->headMeta() ?>
   	<?php echo $this->headLink() ?>
   	<?php echo $this->headScript() ?>
   	
</head>
<body>
				
				<?php 
						$info_username = $this->info_username;
						$info_viewer = $this->info_viewer;
						$list_friend = $this->list_friend;
						$controller = $this->controller;
						$isfriend = $this->isfriend;
						$requesting = $this->requesting;
						$requested = $this->requested;
//						echo $requested;
				?>
	<div class="main_theme"></div>
	<div class="main">
		<div class="logo">
			<table width=100%>
				<tr>
					<td>
						<a href="/<?php echo $this->info_viewer['username']?>"><img src="/images/befriends.png" width=250px /></a>
					</td>
					<td align=right>
						<a href="/<?php echo $this->info_viewer['username']?>/index/logout" style="text-decoration:none;color: white">Log out</a>	
					</td>
				</tr>
			</table>
			
		</div>
		<div class="main_info">
			<div class="user_info">
				<input id="user_name" value="<?php echo $info_username['username']?>" style="display:none" />
				<img src="/images/avatar/<?php echo $info_username['avatar']?>" width=100% />
				<?php if (!$isfriend){
						if (!$requesting){
					?>
				<div style="width:100%;background-image:url('/images/des2.png');color:grey;font-size:13px;margin-top:5px" id="sent" align=center>
					<?php if (!$requested){?>
					<button class="login_button" id="request_button" onclick="friendrequest(<?php echo $this->info_username['id'].",".$this->info_viewer['id']?>)">Add friend</button>
					<?php }else{?>
					<div id="request_result_<?php echo $requested?>" >
						<b>This people want to be your friend</b><br />
						<button class="login_button" onclick="acceptfriend(<?php echo $requested?>)">accept</button>
						<button class="login_button" onclick="refusefriend(<?php echo $requested?>)">refuse</button>
					</div>
					<?php }?>
				</div>
				<?php }
					else {
				?>
				<div style="width:100%;background-image:url('/images/des2.png');color:grey;font-size:13px;margin-top:5px" align=center>
					<b>Request has been sent</b>
				</div>
				<?php }}?>
				<div style="width:100%;background-image:url('/images/des2.png');margin-top:10px;cursor: pointer;" onclick='dpop(<? echo $info_username['id'] ?>)'>
					<?php if ($info_username['id']==$info_viewer['id']){?>	
					<table width=100%>
						<tr>
							<td><img src="/images/penw.png"></img></td>
							<td>
								<?php if (!$info_viewer['description']){?>
								<span>Write something ...</span>
								<?php }else{?>
								<span>Edit</span>
								<?php }?>
							</td>
						</tr>
					</table>
					<?php }?>
				</div>
				<div id="description_edit" width=100% style="display:none;position:absolute">
						<textarea id="re_des" cols="19" rows="12"><?php echo $info_username['description']?></textarea><br />
						
						<button class="login_button" onclick='edes()'>Done</button>
				</div>
				<div id="description" style="background-image:url('/images/des2.png');margin-top:5px;font-size:15px;padding:10px;font-family:arial;font-style:italic">
						<?php echo $info_username['description']?>
				</div>
			</div>
			<div class="menu">
				<table width=100% class="table">
					<tr>
						<td width=40%>
							<b><?php echo $info_username['fullname']?></b>
						</td>
						<td width=20% valign=bottom>
							<a href="/<?php echo $info_username['username']?>/wall" style="text-decoration:none">
							<div class="menu_node <?php if ($controller=='wall') echo 'selected'?>" align=center>
								<b>Status</b>
							</div>
							</a>
						</td>
						<td width=20% valign=bottom>
							<a href="/<?php echo $info_username['username']?>/infomation" style="text-decoration:none">
							<div class="menu_node <?php if ($controller=='info') echo 'selected'?>" align=center>
								<b>Information</b>
							</div>
							</a>
						</td>
						<td width=20% valign=bottom>
							<a href="/<?php echo $info_username['username']?>/friend" style="text-decoration:none">
							<div class="menu_node <?php if ($controller=='friend') echo 'selected'?>" align=center>
								<b>Friends</b>
							</div>
							</a>
						</td>
					</tr>
				</table>
			</div>
			<div class="main-content">
				<?php echo $this->layout()->content ?>
			</div>
		</div>
	</div>
</body>
</html>